# -*- encoding: utf-8 -*-
'''
@File    :   3.py
@Time    :   2022/11/09 23:11:24
@Author  :   Cms 
@Version :   1.0
@Contact :   2267000140@qq.com
@WebSite    :   www.baidu.com
'''

# here put the import lib

# 3 编写一个程序，读取文件中保存的10个学生成绩名单信息(学号,姓名, Python课程分数);
#   然后按照分数从高到低进行排序输出

if __name__ == "__main__":

    with open(r"homework3\grade.txt", "r") as f:

        list1 = []
        for line in f.readlines():
            line = line.strip()
            templist = line.split(" ")
            list1.append(templist)
        # 将列表中成绩一栏转化成整数之后再排序
        for i in list1:
            i[2] = int(i[2])
        list2 = sorted(list1, key=lambda st:st[2],reverse=True)
        print(list2)
